﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OnLineExam.BLL;
using System.Data;

namespace OnlineExam.Web.mag.old
{
    public partial class Web_viewtest : System.Web.UI.Page
    {
        protected int singeCount = 1;
        protected void Page_Load(object sender, EventArgs e)
        {
            OnLineExam.BLL.PaperManager bll = new PaperManager();
            string PaperID = Request.QueryString["PaperID"];
            var p = bll.GetModel(int.Parse(PaperID));
            this.lblPaperName.Text = p.PaperName;
            var probleminfo = p.problemNum.Split(',');
            //题目数
            int singlenum = int.Parse(probleminfo[0].Split(':')[1]);
            int multinum = int.Parse(probleminfo[1].Split(':')[1]);
            int judgenum = int.Parse(probleminfo[2].Split(':')[1]);
            int fillblanknum = int.Parse(probleminfo[3].Split(':')[1]);
            int questionnum = int.Parse(probleminfo[4].Split(':')[1]);

            if (singlenum == 0)
                this.Panel1.Visible = false;

            if (multinum == 0)
                this.Panel2.Visible = false;
            if (judgenum == 0)
                this.Panel3.Visible = false;
            if (fillblanknum == 0)
                this.Panel4.Visible = false;
            if (questionnum == 0)
                this.Panel5.Visible = false;
            //分数
            this.labSingle.Text = probleminfo[0].Split(':')[2];
            this.lbMulti.Text = probleminfo[1].Split(':')[2];
            this.lbJudge.Text = probleminfo[2].Split(':')[2];
            this.lbFillBlank.Text = probleminfo[3].Split(':')[2];
            this.lbQuestion.Text = probleminfo[4].Split(':')[2];





            //string depid=Session["depid"].ToString();

            #region 获取试卷

            var sds = HHG.DBUtility.DbHelperSQL.Query("select top " + singlenum + " * from SingleProblem where depid=" + p.DepID + " and courseid=" + p.CourseID + " order by newid()");


            var mds = HHG.DBUtility.DbHelperSQL.Query("select top " + multinum + " * from MultiProblem where depid=" + p.DepID + " and courseid=" + p.CourseID + " order by newid()");


            var jds = HHG.DBUtility.DbHelperSQL.Query("select top " + judgenum + " * from JudgeProblem where depid=" + p.DepID + " and courseid=" + p.CourseID + " order by newid()");


            var fds = HHG.DBUtility.DbHelperSQL.Query("select top " + fillblanknum + " * from FillBlankProblem where depid=" + p.DepID + " and courseid=" + p.CourseID + " order by newid()");


            var qds = HHG.DBUtility.DbHelperSQL.Query("select top " + questionnum + " * from QuestionProblem where depid=" + p.DepID + " and courseid=" + p.CourseID + " order by newid()");

            this.singleRep.DataSource = sds;
            this.singleRep.DataBind();

            this.rpMulti.DataSource = mds;
            this.rpMulti.DataBind();

            this.rpJudge.DataSource = jds;
            this.rpJudge.DataBind();

            foreach (DataRow item in fds.Tables[0].Rows)
            {
                var newitem = item["FrontTitle"].ToString();
                item["FrontTitle"] = newitem.Replace("_", "<input id=inputtitle name=inputtitle value='' />");
            }

            this.rpFillBlank.DataSource = fds;
            this.rpFillBlank.DataBind();


            this.rpQuestion.DataSource = qds;
            this.rpQuestion.DataBind();

            #endregion

        }
        void getdata()
        {

        }
    }
}